package com.log;

import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;

public class HelloWorld {

    static {
        try {
            // 读取自定义配置文件
            InputStream in = HelloWorld.class.getClassLoader().getResourceAsStream("logging.properties");
            // 获取日志管理器对象
            LogManager logManager = LogManager.getLogManager();
            // 通过日志管理器加载配置文件
            logManager.readConfiguration(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        Logger log = Logger.getLogger(HelloWorld.class.getName());

        log.log(Level.INFO, "INFO");
        log.log(Level.ALL, "ALL");
        log.log(Level.CONFIG, "CONFIG");
        log.log(Level.FINE, "FINE");
        log.log(Level.FINER, "FINER");
        log.log(Level.FINEST, "FINEST");
        log.log(Level.WARNING, "WARNING");
        log.log(Level.SEVERE, "SEVERE");
        log.log(Level.OFF, "OFF");
    }
}
